import {
  REDIRECT_HOME_PATH,
  LAYOUT_NAME,
  LOGIN_NAME,
  NOTFOUND_NAME,
  ERROR_NAME,
} from '@/const/router'

export const basicRoutes = [
  {
    path: '/',
    redirect: REDIRECT_HOME_PATH,
  },
  {
    path: `/${LAYOUT_NAME}`,
    name: LAYOUT_NAME,
    component: () => import('@/layout/index.vue'),
    children: [],
  },
  {
    path: `/${LOGIN_NAME}`,
    name: LOGIN_NAME,
    component: () => import('@/views/login/index.vue'),
    meta: {
      title: '登录',
    },
  },
  {
    path: '/forgetPassword',
    name: 'forgetPassword',
    component: () => import('@/views/forget-password/index.vue'),
    meta: {
      title: '忘记密码',
    },
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/register/index.vue'),
    meta: {
      title: '注册新账号',
    },
  },
]

export const errorRoutes = [
  {
    path: `/${ERROR_NAME}`,
    name: ERROR_NAME,
    component: () => import('@/views/exception/error.vue'),
    meta: {
      title: '错误页面',
      hidden: true,
    },
  },
  {
    path: `/${NOTFOUND_NAME}`,
    name: NOTFOUND_NAME,
    meta: {
      hidden: true,
      title: '404',
    },
    component: () => import('@/views/exception/notfound.vue'),
  },
  // FIXME: 修复路由首次加载时，会先加载404页面
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/views/exception/notfound.vue'),
  },
]
